<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
	<ui:composition template="./main.xhtml">
		<ui:define name="content">
		<f:event listener="#{filesController.initialize}" type="preRenderView"></f:event>
		<br/>
		<h:form enctype="multipart/form-data">
		    <p:growl id="messages" showDetail="true"/>
		    <p:panelGrid columns="2">
			    <p:fileUpload auto="true" update="messages fileList" sizeLimit="102400000" fileUploadListener="#{filesController.upload}"/>
		    </p:panelGrid>
		    <br/>
		    <p:dataTable id="fileList" value="#{filesController.fileList}" var="record">
				<p:column headerText="ファイル名">
					<h:outputText value="#{record.filename}"/>
				</p:column>
				<p:column headerText="アップロード者">
					<h:outputText value="#{record.uploadStaff.formalName}"/>
				</p:column>
				<p:column>
					<p:commandButton value="Delete" action="#{filesController.deleteFile(record)}" ajax="false" styleClass="button_small">
					</p:commandButton>
					<p:commandButton value="Download" ajax="false" styleClass="button_small" onclick="PrimeFaces.monitorDownload(start, stop);">
						<p:fileDownload value="#{filesController.getDownfile(record)}" />
					</p:commandButton>
				</p:column>
			</p:dataTable>
			<p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false">
		        <h:graphicImage name="loading.gif" library="images"/>  
		    </p:dialog>
			<script type="text/javascript">
				function start() {
				    PF('statusDialog').show();
				}
				 
				function stop() {
				    PF('statusDialog').hide();
				}
			</script>
			
		</h:form>
		</ui:define>
	</ui:composition>
</html>